package com.algorithm.thePrimaryAlgorithm;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

@Slf4j
public class ArraySulotionLC07 {
    public int[] plusOne(int[] digits) {
        int[] d = new int[digits.length + 1];
        d[0] = 1;
        int index = 1;
        for (int i = digits.length - 1; i >= 0; i--) {
            if (digits[i] != 9) {
                digits[i]++;
                return digits;
            } else {
                digits[i] = 0;
                d[index] = digits[i];
                index++;
            }
        }
        return d;
    }

    @Test
    public void test(){
        int [] digits = {1,9,9};
        int[] ints = plusOne(digits);
        log.info("over ");
    }
}
